#define _CRT_SECURE_NO_WARNINGS	

#include <stdio.h>
#include<stdlib.h>

typedef struct BinaryTreeNode
{
    char val;
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
}BTNode;

BTNode* Buy_Node(char x)
{
    BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));
    if (newnode == NULL)
    {
        perror("malloc fail!");
        exit(1);
    }
    newnode->val = x;
    newnode->left = newnode->right = NULL;
    return newnode;
}

BTNode* Creat_Tree(char* arr, int* pi)
{
    if (arr[*pi] == '#')
    {
        (*pi)++;
        return NULL;
    }
    BTNode* root = Buy_Node(arr[*pi]);
    (*pi)++;
    root->left = Creat_Tree(arr, pi);
    root->right = Creat_Tree(arr, pi);
    return root;
}
void Mid_Order(BTNode* root)
{
    if (root == NULL)
        return;
    Mid_Order(root->left);
    printf("%c ", root->val);
    Mid_Order(root->right);
}
int main()
{
    char arr[110];
    scanf("%s", arr);
    int i = 0;
    BTNode* root = Creat_Tree(arr, &i);
    Mid_Order(root);
}